<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>登录session测试</title>
    <script type="text/javascript" src="../../js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#loginAction").click(function () {
                var form = $("#loginForm").serializeArray();
                $.ajax({
                    type: "post",
                    url: "http://localhost:8082/myhome/tuser/login",
                    xhrFields: {
                        withCredentials: true,
                    },
                    data: form,
                    dataType: "json",
                    success: function (res) {
                        $("#result").text(res.message);
                    },
                    error: function (errorMsg) {
                        console.log(errorMsg);
                    }
                });
            });
            $("#userList").click(function () {
                $.ajax({
                    type: "post",
                    url: "http://localhost:8082/myhome/tuser/list",
                    xhrFields: {
                        withCredentials: true,
                    },
                    dataType: "json",
                    success: function (res) {
                        $("#result").text(res.message);
                        $("#userResult").text(JSON.stringify(res.data));
                    },
                    error: function (errorMsg) {
                        console.log(errorMsg);
                    }
                });
            });
        });
    </script>
</head>
<body>
<div id="container">
    <p>测试</p>
    <form id="loginForm">
        <input name="uname"/>
        <input name="pword"/>
        <button id="loginAction" type="button">登录</button>
    </form>
    <hr>
    <div id="result"></div>
    <hr>
    <button id="userList" type="button">获取用户列表</button>
    <div id="userResult">

    </div>
</div>
</body>
</html>